package com.mnemonic.player;

import javax.xml.bind.annotation.XmlRootElement;

import com.mnemonic.enums.Grades;
import com.mnemonic.game.Game;
import com.mnemonic.storage.StorageAble;

/**
 * 玩家
 * 
 * @author lifeng
 * @date 2021/05/12
 */
@XmlRootElement
public class Player implements Cloneable, StorageAble {

    private static final long serialVersionUID = 1L;

    protected String id;
    protected String name = "";
    protected String image = "robot.png";
    protected Grades grade = Grades.青铜; // 等级
    protected Integer games = 0; // 玩局数
    protected Integer wins = 0; // 赢局数
    protected Integer scores = 0; // 得分数
    protected Integer faults = 0; // 失误数

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Grades getGrade() {
        return grade;
    }

    public void setGrade(Grades grade) {
        this.grade = grade;
    }

    public Integer getGames() {
        return games;
    }

    public void setGames(Integer games) {
        this.games = games;
    }

    public Integer getWins() {
        return wins;
    }

    public void setWins(Integer wins) {
        this.wins = wins;
    }

    public Integer getScores() {
        return scores;
    }

    public void setScores(Integer scores) {
        this.scores = scores;
    }

    public Integer getFaults() {
        return faults;
    }

    public void setFaults(Integer faults) {
        this.faults = faults;
    }

    public Player initData(Player data) {
        this.setFaults(data.getFaults());
        this.setGames(data.getGames());
        this.setGrade(data.getGrade());
        this.setScores(data.getScores());
        this.setWins(data.getWins());
        return this;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.name).append(" 等级：").append(this.grade);
        return sb.toString();
    }

    @Override
    public Player clone() throws CloneNotSupportedException {
        return (Player)super.clone();
    }

    /**
     * 自动排雷
     */
    public void autoMine(Game game, RobotMineListener listener) {

    }
}